package com.red.star.wechat.data.mappers;

import com.red.star.wechat.data.core.base.MyMapper;
import com.red.star.wechat.data.entity.Vip;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * @author AMGuo
 * @Description 会员
 * @date 2018/03/03 16:24
 */
public interface VipMapper extends MyMapper<Vip> {

    @Select(value = "select * from t_vip t where t.vip_open_id = #{vipOpenId} AND t.vip_open_id IS NOT NULL AND t.vip_open_id != '' AND t.vip_open_id != 'null' AND t.vip_open_id != 'undefined'")
    public Vip getVipByVipOpenId(String vipOpenId);

    @Select(value = "select * from t_vip t where t.vip_id = #{vipId}")
    public Vip getVipByVipId(String vipId);

    @Select(value = "select count(t.id) from t_vip t where t.vip_open_id = #{vip.vipOpenId}")
    Integer countSelective(@Param("vip") Vip vip);

    @Select(value = "select t.id from t_vip t where t.vip_open_id = #{vip.vipOpenId} AND t.vip_open_id IS NOT NULL AND t.vip_open_id != '' AND t.vip_open_id != 'null' AND t.vip_open_id != 'undefined'")
    Integer findSelective(@Param("vip") Vip vip);

    @Select(value = "select t.id from t_vip t where t.vip_open_id = #{vipOpenId} AND t.vip_open_id IS NOT NULL AND t.vip_open_id != '' AND t.vip_open_id != 'null' AND t.vip_open_id != 'undefined'")
    Integer getIdByVipOpenId(String vipOpenId);
}
